<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        img{
            width: 50px;height: 50px;
        }
    </style>
</head>
<body>
<input type="text" placeholder="请输入数量">
<input type="button" value="帅哥" onclick="f(1)">
<input type="button" value="美女" onclick="f(2)">
<script>
    let i = document.querySelector("input");
    function f(x){
        for(let j=0;j<i.value;j++){
            let imgName = x==1?"../a.jpg":"../b.jpg";
            let img = document.createElement("img");
            img.src = imgName;
            document.body.append(img);
        }
    }
</script>

</body>
</html>